package com.ysu.zyw.tool;

public class ThreeTuple<K, V, T> extends Tuple<K, V> {

    private static final long serialVersionUID = 1563905060106229272L;

    private T thirdValue;

    public ThreeTuple(K firstValue, V secondValue, T thirdValue) {
        super(firstValue, secondValue);
        this.thirdValue = thirdValue;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + ((thirdValue == null) ? 0 : thirdValue.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!super.equals(obj))
            return false;
        if (getClass() != obj.getClass())
            return false;
        @SuppressWarnings("rawtypes")
        ThreeTuple other = (ThreeTuple) obj;
        if (thirdValue == null) {
            if (other.thirdValue != null)
                return false;
        } else if (!thirdValue.equals(other.thirdValue))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "ThreeTuple [thirdValue=" + thirdValue + ", toString()=" + super.toString() + "]";
    }

    public T getThirdValue() {
        return thirdValue;
    }

    public void setThirdValue(T thirdValue) {
        this.thirdValue = thirdValue;
    }

}
